package util;

import java.util.Vector;

import ns2.Node;

public class Nodes extends Vector<Node> {

	private static final long serialVersionUID = 1L;

	public void addNode(Node n) {
		boolean exist = false;
		for (int i = 0; i < this.size(); i++) {
			exist = exist || (this.elementAt(i).id == n.id);
		}
		if (!exist)
			this.addElement(n);
	}

	public Node getNode(int id) {
		for (int i = 0; i < this.size(); i++) {
			if (this.elementAt(i).id == id) {
				return this.elementAt(i);
			}
		}
		return null;
	}

	public Node nodeAt(int index) {
		return this.elementAt(index);
	}
	
	public void compact(){
		this.trimToSize();
	}

}
